<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //1  typeof 只能检测简单的数据类型
      console.log(typeof {}, typeof []);
      //2    instanceof Array   //不能区分数组和对象
      console.log([] instanceof Array);
      //3   Array.isArray( 要检测的类型)  IE9以上才支持
      console.log([]);

      // 检测所有数据类型  最牛没有之一
      console.log(Object.prototype.toString.call('')); //[object String]
      console.log(Object.prototype.toString.call(true)); //[object Boolean]
      console.log(Object.prototype.toString.call(666)); //[object Number]
      console.log(Object.prototype.toString.call(new Date())); //[object Date]
      console.log(Object.prototype.toString.call([])); //[object Array]
      console.log(Object.prototype.toString.call({})); //[object Object]
    </script>
  </body>
</html>
